<script setup lang="ts">

import {ref} from "vue";


let sth = ref('');
/* top 调用  sub 方法*/
const dosth = (e: string) => {
  alert(e)
  sth.value = e
}
/* sub 调用 top void 方法*/
const callTopM1 = () => {
  emit('isOk')
}
/* sub 调用 top args 方法*/
const callTopM2 = () => {
  const data = new Date().toLocaleString()
  emit('sendData', data)
}

defineProps<{ msg: string, age: number }>()

const emit = defineEmits<{
  isOk: []
  sendData: [data: string]
}>();

defineExpose({
  dosth
})


</script>

<template>
  <h3> sub content </h3>
  <h3>{{ sth }}</h3>
  <h3>{{ msg }}</h3>
  <p>{{ age }}</p>

  <button @click="callTopM1">call Top Method</button>
  <button @click="callTopM2">call Top Method args</button>

</template>

<style scoped>
</style>
